using System;
using System.Collections.Generic;
using FPLibrary;

namespace Pvp.Ecs
{
    /// <summary>
    /// unit 视野状态刷新，
    /// </summary>
    public class UnitViewSystem : ISystem
    {
        private IStage viewer;

        public override void OnStart()
        {
            viewer = Entities.GetSingleComponent<IStage>();
        }

        public override void OnFrameExecute(int frameIndex)
        {
            UnityEngine.Debug.Log("8900000dd");

            return;
            //可以每隔n个逻辑帧刷新一下视野
            
            var units = Entities.GetComponents<IUnit>();
            foreach (var unit in units)
            {
                if (unit.TryGetCombineComponent<IView>(out var view))
                {
                    view.IsInView = FPVector.Distance(viewer.CenterPoint, unit.Position) <= viewer.ViewRadius;
                }
            }
        }
    }

    /// <summary>
    /// stage
    /// </summary>
    public class StageSystem : ISystem
    {
        //private IStage
        public override void OnStart()
        {

        }

        public override void OnFrameExecute(int frameIndex)
        {
            
        }
    }
}